<?
header("Content-type:text/html; charset=utf-8");
include ("../conn.php");
$gctype = "DAOHANG_MENU";
$gcid = trim($_GET['cid']);
$act =  trim($_GET['act']);
//添加操作
if(isset($_POST['submit']) && ($act==""||$act=="create")){
	$ctitle = trim(mysql_real_escape_string($_POST['CTITLE']));
	$ccontent = trim(mysql_real_escape_string($_POST['CCONTENT']));
	$cseq = intval($_POST['CSEQ']);
	if(empty($ctitle)||empty($ccontent)){
		echo "菜单名和连接地址都不可为空！<a href='admin_menu.php'>返回</a>";
		exit;
	}
	$sql = "insert into ".$databasepre."common(CTYPE,CTITLE,CCONTENT,CSEQ) values ('".$gctype."','".$ctitle."','". $ccontent."',".$cseq.") ";
	mysql_query($sql);
	echo "添加成功!<a href=admin_menu.php>返回</a>";
	exit;
}
//修改操作
if(isset($_POST['submit']) && $act=="update"){
	$ctitle = trim(mysql_real_escape_string($_POST['CTITLE']);
	$ccontent = trim(mysql_real_escape_string($_POST['CCONTENT']));
	$cseq = intval($_POST['CSEQ']);
	if(empty($ctitle)||empty($ccontent)){
		echo "菜单名和连接地址都不可为空！<a href='admin_menu.php'>返回</a>";
		exit;
	}

	$sql = "update ".$databasepre."common set CTITLE='".$ctitle."',CCONTENT='".$ccontent."',CSEQ=".$cseq." where CID=".$gcid;
	mysql_query($sql);
	echo "修改成功!<a href=admin_menu.php>返回</a>";exit;
}
//删除操作
if($_GET['cid']&&$_GET['act']=="del")
{
	$delsql="delete from ".$databasepre."common where ctype='".$gctype."' and cid='".$gcid."'";
	mysql_query($delsql);
	echo "删除成功!<a href=admin_menu.php>返回</a>";exit;
}
?>
<html><head>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif">
		<table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
		  <tr><td height="31"><div class="titlebt">常规管理</div></td></tr>
		</table>
	</td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9">
	<!-- 网页内容部分开始 -->


	<table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr><td height="13" valign="top">&nbsp;</td></tr>
	  <tr><td class="left_txt">当前位置：导航菜单管理</td></tr>
	  <!-- 一根线 -->
	  <tr><td height="20"><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"><tr><td></td></tr></table></td></tr>
	  <!-- 说明信息 -->
	  <tr><td><table width="100%" height="55" border="0" cellpadding="0" cellspacing="0"><tr>
				<td width="10%" height="55" valign="middle"><img src="images/title.gif" width="54" height="55"></td>
				<td width="90%" valign="top"><span class="left_txt2">在这里，您可以根据您的网站要求，修改设置网站的导航菜单！目前系统自带的导航菜单如下:</span><br>
						  <span class="left_txt2">1.Home 地址:indxe.php</span>
						  <span class="left_txt2">2.Products 地址:productlist.php</span><br/>
						  <span class="left_txt2">3.Buying   Leads 地址:buyofferlist.php</span>
						  <span class="left_txt2">4.TrustPass   Profile 地址:trustpass_profile.php</span><br/>
						  <span class="left_txt2">5.About Us 地址:aboutus.php</span>
						  <span class="left_txt2">6.Contacts 地址:contactinfo.php</span><br/></td>
				</tr></table>
		</td>
	  </tr>
	  <tr><td>&nbsp;</td></tr>
	  <tr><td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
				  <tr><td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;导航菜单管理【<a href=?act=create> 新 增 </a>】</td></tr>
				</table>
		</td>
      </tr>
	  <tr><td><table width="700" border="0" cellspacing="0" cellpadding="0">
				<form method=POST action="">

					<tr bgcolor="#f2f2f2">
						<th width="100" class="left_txt" align=left></th>
						<th width="200" height="30" class="left_txt2" align=left>菜单名称</th>
						<th width="200" class="left_txt2" align=left>地址路径</th>
						<th width="100" class="left_txt2" align=left>排序[升序]</th>
						<th width="100" class="left_txt2" align=left>操作</th>
					</tr>

					<?php if($act=="" || $act=="create") { ?>
					<tr>
					<td height="30"></td>
					<td align=left><input type="text" name="CTITLE" value="" size="20" maxlength="40"/></td>
					<td align=left><input type="text" name="CCONTENT" value="" size="20" maxlength="40"/></td>
					<td align=left><input type="text" name="CSEQ" value="" size="5" maxlength="40"/></td>
					<td align=left><input type="submit" name="submit" value="添加" /></td>
					</tr>
					<?php
					}else if($act=="update"){
					$sql="select * from ".$databasepre."common WHERE CID=".$gcid;
					$query=mysql_query($sql);
					$row=mysql_fetch_array($query);
					echo '<tr>';
					echo '<td height="30"></td>';
					echo '<td align=left><input type="text" name="CTITLE" value="'.$row['CTITLE'].'" size="20" maxlength="80"/></td>';
					echo '<td align=left><input type="text" name="CCONTENT" value="'.$row['CCONTENT'].'" size="20" maxlength="200"/></td>';
					echo '<td align=left><input type="text" name="CSEQ" value="'.$row['CSEQ'].'" size="5" maxlength="4"/></td>';
					echo '<td align=left><input type="submit" name="submit" value="修改" /></td>';
					echo '</tr>';

					}
					$tdstyle="";
					$tdi = 0;
					$sql="select * from ".$databasepre."common where CTYPE='DAOHANG_MENU' order by CSEQ asc,CID desc";
					//echo $sql."<br/>";
					$query=mysql_query($sql);
					while($corprow=mysql_fetch_array($query))
					{
					$tdi = $tdi + 1;
					if($tdi%2 == 0) { $tdstyle = "f2f2f2"; }else{ $tdstyle = ""; }

					echo '<tr bgcolor='.$tdstyle.'>';
					echo '<td height="30"></td>';
					echo '<td align=left>'.$corprow['CTITLE'].'</td>';
					echo '<td align=left>'.$corprow['CCONTENT'].'</td>';
					echo '<td align=left>'.$corprow['CSEQ'].'</td>';
					echo '<td align=left><a href=?act=update&cid='.$corprow['CID'].'>修改</a> <a href=?act=del&cid='.$corprow['CID'].'>删除</a></td>';
					echo '</tr>';
					}
					?>
				</form>
			  </table>
			</td>
		</tr>



	 </table>






	<!-- 网页内容部分结束 -->
	</td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
    <td background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</body>
</html>
